import React from 'react'
import { Button, Select, } from 'antd'
import { UdModal, UdModalForm, validators, UdDatePicker } from '../../../../index'

const { Option } = Select

const Demo = () => {
  return <div>
    <p>编辑数据时传入一个values即刻实现数据回显</p>
    <Button type="primary" onClick={openModal}>打开弹窗</Button>
  </div>
}

const data: any = {
  name: '回显名称',
  code: 'JMM',
  creatTime: '2019-12-27'
}

const openModal = () => {
  UdModal.open({
    title: '编辑',
    maskClosable: false,
    content: <UdModalForm values={data} items={[
      { id: 'name', label: '应用名称', rules: [validators.required] },
      {
        id: 'code', label: '应用code', rules: [validators.required], render: <Select>
          <Option value="JMM">玖妈妈</Option>
          <Option value="GBCK">隔壁仓库</Option>
          <Option value="CH">吃喝</Option>
        </Select>
      },
      {
        id: 'creatTime', label: '创建时间', render: <UdDatePicker style={{ width: '100%' }} />
      }

    ]} />,
    okText: '确定',
    cancelText: '取消',
    onOk: (values) => {
      console.log(values)
    }
  })
}

export default Demo
